#include <Def.h>
#include <qdebug.h>
#include "AnnoItemPrivate.h"
#include "ObjectFactory.h"

class AnnoItem_FatureNode_Polygon : public AnnoItem_FatureNode
{
	static QSet<QString> propertySet;
public:
	AnnoItem_FatureNode_Polygon();
	~AnnoItem_FatureNode_Polygon();
public:
	QString getAnnoItemTypeString()const
	{
		return QString("polygon");
	}

	void setProperty(const Property& property);
	bool containProperty(const QString& key);
	QStringList getPropertyNameList()const;
protected:
	AnnoGeometry geometry;
	osgEarth::Features::Feature* feature = nullptr;
};

QSet<QString> AnnoItem_FatureNode_Polygon::propertySet({"push_back"});

OBJECT_REGSTER_IMPL(AnnoItem,AnnoItem_FatureNode_Polygon,QString,QString("polygon"))

AnnoItem_FatureNode_Polygon::AnnoItem_FatureNode_Polygon()
{
	geometry.polygon = new osgEarth::Symbology::Polygon();

	const auto srs = GLOBAL_OSG_MAP_NODE->getMapSRS();
	feature = new osgEarth::Features::Feature(geometry.polygon,srs);
	feature->geoInterp() = osgEarth::Features::GEOINTERP_GREAT_CIRCLE;

	auto style = SDKCore::instance()->getStyleManager()->getPrivateClass()->getOsgStyleByName("polygon-style");
	annoNode.feature = new osgEarth::Annotation::FeatureNode(GLOBAL_OSG_MAP_NODE,feature,style);
	annoNode.feature->setDynamic(true);
}

AnnoItem_FatureNode_Polygon::~AnnoItem_FatureNode_Polygon()
{
}

void AnnoItem_FatureNode_Polygon::setProperty(const Property& property)
{
	ANNO_APPEND_FATURE_NODE_POINT(geometry.polygon)
	annoNode.feature->dirty();
}

bool AnnoItem_FatureNode_Polygon::containProperty(const QString& key)
{
	return propertySet.contains(key);
}

QStringList AnnoItem_FatureNode_Polygon::getPropertyNameList()const
{
	return propertySet.toList();
}